package com.bstech.Classi;

import com.bstech.Tabelle.Tecnici.Tecnico;

import android.content.Context;
import android.os.Environment;
import android.widget.Toast;

public class Common {

	/* VALORI DELLE ATTIVITA' UTILIZZATI PER RITORNO */
	public static final int ACTIVITY_CHIAMATE = 1;
	public static final int ACTIVITY_CHIAMATA = 2;
	public static final int ACTIVITY_CAMERA = 3;
	public static final int ACTIVITY_SIGN = 4;
	public static final int ACTIVITY_RAPPORTINI_SETTINGS = 5;
	public static final int ACTIVITY_CHIAMATE_SETTINGS = 6;
	public static final int ACTIVITY_ALLEGATI = 7;
	public static final int ACTIVITY_NUOVA_CHIAMATA = 8;

	public static final int ACTIVITY_SELECTOR_CLIENTE = 9;
	public static final int ACTIVITY_SELECTOR_DESTINAZIONE = 10;
	public static final int ACTIVITY_SELECTOR_IMPIANTO = 11;
	public static final int ACTIVITY_SELECTOR_ORE_ORDINARIE = 12;
	public static final int ACTIVITY_SELECTOR_ORE_STRAORDINARIE = 13;
	public static final int ACTIVITY_SELECTOR_COMMESSA = 14;

	/* VALORI DELLE NOTIFICHE UTILIZZATI PER RITORNO */
	public static final int NOTIFY_SYNC = 1;
	public static final int NOTIFY_UPDATE = 2;

	/* VARIABILI DI PROGETTO */
	// PERCORSI
	public static final String AppPath = Environment
			.getExternalStorageDirectory() + "/Assistenza/";
	public static final String DBFilePath = AppPath + "Db/";
	public static final String DBFile = AppPath + "Db/data";
	public static final String SignaturesFilePath = AppPath + "Signatures/";
	public static final String AttachmentsFilePath = AppPath + "Attachments/";
	public static final String SettingsFilePath = AppPath + "settings.dat";
	public static final String UpdatesFilePath = AppPath + "Updates/";

	// OGGETTI
	public static Tecnico CurrentUser;

	// CLASSI
	private static ClassSettings mSettings = null;

	public static ClassSettings Settings() {
		if (mSettings == null) {
			mSettings = ClassSettings.Deserialize(SettingsFilePath);
		}
		return mSettings;
	}

	public static void ReloadSettings() {
		mSettings = ClassSettings.Deserialize(SettingsFilePath);
	}

	/* MESSAGE BOX */
	public static void MsgBox(Context context, String msg) {
		Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
	}

	public static void MsgBox(Context context, int ResourceMsg) {
		Toast.makeText(context, context.getString(ResourceMsg),
				Toast.LENGTH_SHORT).show();
	}
	public static void MsgBoxLong(Context context, String msg) {
		Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
	}

	public static void MsgBoxLong(Context context, int ResourceMsg) {
		Toast.makeText(context, context.getString(ResourceMsg),
				Toast.LENGTH_LONG).show();
	}

	private static String deviceID;
	public static String getDeviceID()
	{
		return deviceID;
	}
	public static void setDeviceID(String uid)
	{
		deviceID = uid;
	}
	
	/* GESTIONE DATABASE */
	public static SqlDb db;

	public static void InitDB(Context context) {
		if (db == null)
			db = new SqlDb(context);
		db.Open();
	}
	
}